﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Diagnostics;

namespace MacroApp
{
    public partial class FrmHelps : Form
    {
        public FrmHelps()
        {
            InitializeComponent();
        }

        private void btncancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void FrmHelps_Load(object sender, EventArgs e)
        {
            lblLicensed.Text = System.Net.Dns.GetHostName();
            string appPath = string.Format(@"{0}\Help.txt", Path.GetDirectoryName(Application.ExecutablePath));
            if (File.Exists(appPath))
            {
                OpenFile(appPath);                
            }
            else {
                rtxHelp.Text = "Can't load file help.txt";
            }
        }
        
        #region Function
        
        public void OpenFile(string strFileName)
        {
            string strFileContents = "";
            try
            {
                strFileContents = File.ReadAllText(strFileName);
            }
            //return false if problem opening file
            catch (Exception) { MessageBox.Show("Not a valid file!"); }
            if (strFileContents != "")
            {
                Functions.AddColouredText(strFileContents, rtxHelp);
            }
        }
        #endregion

        private void linkLabel3_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            string appPath = string.Format(@"{0}\mailEmpty.txt", Path.GetDirectoryName(Application.ExecutablePath));
            if (File.Exists(appPath))
            {
                Process.Start("notepad.exe", appPath);
            }
        }

        private void linkLabel4_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            string appPath = string.Format(@"{0}\mailFull.txt", Path.GetDirectoryName(Application.ExecutablePath));
            if (File.Exists(appPath))
            {
                Process.Start("notepad.exe", appPath);
            }
        }
    }
}
